/**
 * @author      Liu Yongshuai<liuyongshuai@hotmail.com>
 * @date        2018-03-27 15:20
 */
package utils

import (
	"cron_table_admin/global"
	"fmt"
	"math/rand"
	"strings"
	"time"
)

var (
	LocalHostIP        = ""
	LocalHostIpArr     []string
	LocalHostIpTraceId = ""
	preTraceID         = ""
	ScreenWidth        int
	ScreenHeight       int
)

//重新设置随机数种子
func ReRandSeed() {
	genId, err := global.UniqId.NextId()
	if err != nil {
		rand.Seed(time.Now().UnixNano())
	} else {
		rand.Seed(genId)
	}
}

func GetOSAudit(os int) (b bool) {
	if os == 1 {
		b = global.VIPER_CONFIG.GetBool("system.ios-audit")
	} else {
		b = global.VIPER_CONFIG.GetBool("system.android-audit")
	}
	fmt.Print(b)
	return
}

func CheckoutVersion(version string, os int) (b bool, err error) {
	var standerVersion int
	if os == 1 {
		standerVersion = global.VIPER_CONFIG.GetInt("system.ios-version")
	} else {
		standerVersion = global.VIPER_CONFIG.GetInt("system.android-version")
	}

	global.LOGGER.Info(IntToString(standerVersion))
	strVersion := strings.ReplaceAll(version, ".", "")
	requestVersion, _ := StringToInt(strVersion)
	if requestVersion >= standerVersion {
		b = true
	} else {
		b = false
	}
	return
}
